package com.example.javaproject.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.javaproject.entity.Student;
import com.example.javaproject.mapper.StudentMapper;
import com.example.javaproject.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student getByUserId(Integer userId) {
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId).eq("is_deleted", 0);
        return studentMapper.selectOne(wrapper);
    }

    @Override
    public boolean updateById(Student student) {
        return studentMapper.updateById(student) > 0;
    }


}